package com.dianzhihan.cashier.model.product;

import com.dianzhihan.cashier.controller.ErrorRedirectException;
import com.dianzhihan.cashier.model.AbsValidator;

/**
 * @author Dianzhi Han
 * @version 1.0
 * @description: 商品单位的合法性校验
 * @date 2023/2/9 12:13
 */
public class UnitValidator extends AbsValidator {
    @Override
    public String validate(String unit, String module, String redirectUrl) {
        unit =  super.validate(unit, module, redirectUrl);

        if (unit.length() > 10) {
            throw new ErrorRedirectException("unit 的长度超过 10", module, redirectUrl);
        }

        return unit;
    }
}
